package com.mengniu.common.social.config.enums;

import com.mengniu.common.social.config.properties.SocialLoginConfigProperties;
import me.zhyd.oauth.request.*;

import java.util.function.Function;

public enum SourceEnum {


    mengniu98k(AuthRequestFactory.megnniuFunction),

    dingtalk(AuthRequestFactory.dingtalkFunction),
    baidu(AuthRequestFactory.baiduFunction),
    github(AuthRequestFactory.githubFunction),
    gitee(AuthRequestFactory.giteeFunction),
    weibo(AuthRequestFactory.weiboFunction),
    coding(AuthRequestFactory.codingFunction),
    oschina(AuthRequestFactory.oschinaFunction),
    alipay_wallet(AuthRequestFactory.alipay_walletFunction),
    qq(AuthRequestFactory.qqFunction),
    wechat_open(AuthRequestFactory.wechat_openFunction),
    taobao(AuthRequestFactory.taobaoFunction),
    douyin(AuthRequestFactory.douyinFunction),
    linkedin(AuthRequestFactory.linkedinFunction),
    microsoft(AuthRequestFactory.microsoftFunction),
    renren(AuthRequestFactory.renrenFunction),
    stack_overflow(AuthRequestFactory.stack_overflowFunction),
    huawei(AuthRequestFactory.huaweiFunction),
    wechat_enterprise(AuthRequestFactory.wechat_enterpriseFunction),
    gitlab(AuthRequestFactory.gitlabFunction),
    wechat_mp(AuthRequestFactory.wechat_mpFunction),
    aliyun(AuthRequestFactory.aliyunFunction);

    private Function<SocialLoginConfigProperties, AuthRequest> function = AuthRequestFactory.megnniuFunction;

    SourceEnum(Function<SocialLoginConfigProperties, AuthRequest> function) {
        this.function = function;
    }

    SourceEnum() {
    }

    public static AuthRequest getSourceEnum(String source, SocialLoginConfigProperties obj) {
        for (SourceEnum sourceEnum : SourceEnum.values()) {
            if (sourceEnum.name().equals(source)) {
                return sourceEnum.function.apply(obj);
            }
        }
        return null;
    }

}
